﻿<cmn:UserControlBase x:Class="Hopscotch.Presentation.Controls.Core.InstrumentControl"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 			 
             xmlns:system="clr-namespace:System;assembly=mscorlib"
             xmlns:toolkit="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Input.Toolkit"
             xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
             xmlns:cmn="clr-namespace:Hopscotch.Presentation.Common;assembly=Hopscotch.Presentation.Common"
             xmlns:cmnCnvrtrs="clr-namespace:Hopscotch.Presentation.Common.Converters;assembly=Hopscotch.Presentation.Common"
             
             x:Name="InstrumentUserControl"			 			 
             mc:Ignorable="d" 
             d:DesignHeight="25" d:DesignWidth="300">

    <cmn:UserControlBase.Resources>
        <ResourceDictionary Source="../Resources/ErrorContentControl.xaml" />
    </cmn:UserControlBase.Resources>

    <ContentControl Template="{StaticResource ErrorContentControl}" IsTabStop="False">

        <toolkit:AutoCompleteBox x:Name="instrumentAutoComplete"
                                 Validation.ErrorTemplate="{x:Null}"
                                 ValueMemberPath="Symbol"
                                 SelectedItem="{Binding Instrument, ElementName=InstrumentUserControl, Mode=TwoWay}"
                                 IsTextCompletionEnabled="False"
                                 Margin="0 0 0 0"
                                 BorderThickness="0">
            <toolkit:AutoCompleteBox.Style>
                <Style TargetType="{x:Type toolkit:AutoCompleteBox}">
                    <Setter Property="IsTabStop" Value="False"/>
                    <Setter Property="Template">
                        <Setter.Value>
                            <ControlTemplate TargetType="{x:Type toolkit:AutoCompleteBox}">
                                <Grid Opacity="{TemplateBinding Opacity}">
                                    <xctk:AutoSelectTextBox x:Name="Text" IsTabStop="True"
                                                            AutoSelectBehavior="OnFocus"
                                                            BorderThickness="0"
                                                            Background="{Binding Path=Background, ElementName=InstrumentUserControl}"/>
                                    <Popup x:Name="Popup" StaysOpen="False">
                                        <ListView x:Name="Selector">
                                            <ListView.View>
                                                <GridView AllowsColumnReorder="False">
                                                    <GridViewColumn Header="Symbol" DisplayMemberBinding="{Binding Path=Symbol}" />
                                                    <GridViewColumn Header="Name" DisplayMemberBinding="{Binding Path=Name}" />
                                                </GridView>
                                            </ListView.View>
                                        </ListView>
                                    </Popup>
                                </Grid>
                            </ControlTemplate>
                        </Setter.Value>
                    </Setter>
                </Style>
            </toolkit:AutoCompleteBox.Style>
        </toolkit:AutoCompleteBox>

    </ContentControl>
</cmn:UserControlBase>
